#ifndef __CLOCK_H
#define __CLOCK_H
#include<iostream>
#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<unistd.h>


using namespace std;

class Clock
{
public:
	Clock() 
	{ 
		isClicked = false;
	}
	~Clock() { }
	void click()
	{
		time(&rawtime);
		ptminfo = localtime(&rawtime);
		gettimeofday(&stime, NULL);
		if(isClicked==false)isClicked=true;
		sprintf(strTimeClicked, "current:%02d-%02d-%02d %02d:%02d:%02d:%02ld",
					ptminfo->tm_year + 1900, ptminfo->tm_mon + 1, ptminfo->tm_mday,
					ptminfo->tm_hour , ptminfo->tm_min, ptminfo->tm_sec, stime.tv_usec/1000);
	}
	void printTime()
	{
		if(isClicked==true)
			/*
			printf("current:%02d-%02d-%02d %02d:%02d:%02d:%02d\n",
					ptminfo->tm_year + 1900, ptminfo->tm_mon + 1, ptminfo->tm_mday,
					ptminfo->tm_hour , ptminfo->tm_min, ptminfo->tm_sec, stime.tv_usec/1000);
			*/
			printf("%s", strTimeClicked);
	}
//privatet:
	//get s
	time_t rawtime;
	struct tm *ptminfo;
	//get us
	struct timeval stime;
	//empty check
	bool isClicked;
	//time string
	char strTimeClicked[50];

};

/*
int main(int argc, char *argv[])
{
	
	Clock clock;
	clock.click();
	clock.printTime();	
	
	exit(0);
}
*/

#endif
